package com.yang.controller.admin;

import com.yang.bean.MarketKeyWord;
import com.yang.bean.common.BasePageInfo;
import com.yang.bean.common.BaseRespVo;
import com.yang.bean.common.CommonData;
import com.yang.bean.zdd.bo.CreateKeywordBo;
import com.yang.bean.zdd.bo.UpdateKeywordBo;
import com.yang.bean.zdd.vo.CreateKeywordVo;
import com.yang.service.admin.KeywordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName AdminKeywordController
 * @Description TODO 关键词模块
 * @Author zhangdongdong
 * @Date 2022/9/6 19:56
 * @Version 1.0
 */
@RestController
@RequestMapping("admin/keyword")
public class AdminKeywordController {
    @Autowired
    KeywordService keywordService;

    @RequestMapping("list")
    public BaseRespVo list(BasePageInfo basePageInfo, String keyword, String url) {
        CommonData<MarketKeyWord> data = keywordService.list(basePageInfo, keyword, url);
        return BaseRespVo.ok(data);
    }

    @RequestMapping("create")
    public BaseRespVo create(@RequestBody CreateKeywordBo createKeywordBo) {
        CreateKeywordVo data = keywordService.create(createKeywordBo);
        return BaseRespVo.ok(data);
    }

    @RequestMapping("update")
    public BaseRespVo update(@RequestBody UpdateKeywordBo updateKeywordBo) {
        MarketKeyWord data = keywordService.update(updateKeywordBo);
        return BaseRespVo.ok(data);
    }

    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody MarketKeyWord marketKeyWord) {
        keywordService.delete(marketKeyWord);
        return BaseRespVo.ok(null);
    }
}
